import cv2
import numpy as np

cv2.namedWindow('image')
filename = '../images/card10.png'
img = cv2.imread(filename, 0)
cv2.createTrackbar('num', 'image', 0, 255, lambda x: None)

while(1):
    num = cv2.getTrackbarPos('num', 'image')
    ret, thr = cv2.threshold(img, num, 255, cv2.THRESH_BINARY)
    cv2.imshow('image', thr)
    if cv2.waitKey(1) & 0xFF == 27:
        break

cv2.destroyAllWindows()
